package com.iss.umservice.manager.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iss.iframework.common.errcode.AppRuntimeException;
import com.iss.umservice.bean.ServiceApplyBean;
import com.iss.umservice.bean.ServiceBean;
import com.iss.umservice.common.UMServiceErrorKey;
import com.iss.umservice.dao.ServiceDao;
import com.iss.umservice.manager.ServiceManager;

@Service
public class ServiceManagerImpl implements ServiceManager {
	@Autowired
	private ServiceDao serviceDao;

	public ServiceBean queryServiceInfo(String serviceID) {
		// TODO Auto-generated method stub
		return serviceDao.queryServiceInfo(serviceID);
		
	}

	public List<ServiceBean> queryServiceList(ServiceBean serviceBean,int offset ,int row) {
		// TODO Auto-generated method stub
		return serviceDao.queryServiceList(serviceBean, offset, row);
		
	}

	

	public void createService(ServiceBean servicebean) {
		// TODO Auto-generated method stub
		serviceDao.createService(servicebean);
	}

	public void modService(ServiceBean servicebean) {
		// TODO Auto-generated method stub
		serviceDao.modService(servicebean);
	}

	public int countServiceInfo(ServiceBean serviceBean) {
		// TODO Auto-generated method stub
		return serviceDao.countServiceInfo(serviceBean) ;
	}

	public void delService(String serviceID) {
		// TODO Auto-generated method stub

		serviceDao.delService(serviceID);
		
	}


	public void applyService(ServiceApplyBean serviceApplyBean) {
		// TODO Auto-generated method stub
		//����ǻ������룬��ҪУ���Ƿ��Ѿ���Ԥ��
		if(serviceApplyBean.getServiceType().equals("8")&&"2".equals(serviceApplyBean.getStatus()))
		{
			if(serviceDao.isApplyed(serviceApplyBean))
			{
				throw new AppRuntimeException(UMServiceErrorKey.ISAYYLYED, "���������ʧ��", new Exception(""));
			}
		}
		serviceDao.applyService(serviceApplyBean);
	}

	public void approveService(ServiceApplyBean serviceApplyBean) {
		// TODO Auto-generated method stub
		//����ǻ������룬��ҪУ���Ƿ��Ѿ���Ԥ��
		if("8".equals(serviceApplyBean.getServiceType()))
		{
			if(serviceDao.isApplyed(serviceApplyBean))
			{
				throw new AppRuntimeException(UMServiceErrorKey.ISAYYLYED, "���������ʧ��", new Exception(""));
			}
		}
		serviceDao.approveService(serviceApplyBean);
	}

	public void delServiceApplyInfo(String ID) {
		// TODO Auto-generated method stub
		serviceDao.delServiceApplyInfo(ID);
	}

	public int countServiceApplyInfo(ServiceApplyBean serviceApplyBean) {
		// TODO Auto-generated method stub
		return serviceDao.countServiceApplyInfo(serviceApplyBean);
	}

	public List<ServiceApplyBean> queryServiceApplyList(
			ServiceApplyBean serviceApplyBean, int offset, int rowSize) {
		// TODO Auto-generated method stub
		return serviceDao.queryServiceApplyList(serviceApplyBean,offset,rowSize);
	}
	
	public List<ServiceApplyBean> queryMeetingApplyInfo(String serviceId)
	{
		return serviceDao.queryMeetingApplyInfo(serviceId);	
		
	}

}
